﻿using System;

namespace ComparesArraysLexicographicaly
{
    class ComparesArraysLexicographicaly
    {
        static void PrintCharArray(char[] charArray)
        {
            Console.WriteLine("First: {0}", new String(charArray));
        }
        static void ComparesLexicographicaly(char[] firstArray, char[] secondArray)
        {
            int length;
            char[] winner = "Equal".ToCharArray();
            bool equalLength = false,
                isFound = false;

            if (firstArray.Length == secondArray.Length)
            {
                length = secondArray.Length;
                equalLength = true;
            }
            else
            {
                length = Math.Min(firstArray.Length, secondArray.Length);
            }
            for (int character = 0; character < length; character++)
            {
                if (firstArray[character] != secondArray[character])
                {
                    winner = firstArray[character] < secondArray[character] ? firstArray : secondArray;
                    isFound = true;
                    break;
                }
            }
            if (!isFound && !equalLength)
            {
                winner = firstArray.Length > secondArray.Length ? secondArray : firstArray;
            }
            PrintCharArray(winner);
        }

        static void Main(string[] args)
        {
            Console.Write("Enter a string: ");
            char[] firstArray = Console.ReadLine().ToCharArray();
            Console.Write("Enter a string: ");
            char[] secondArray = Console.ReadLine().ToCharArray();
            ComparesLexicographicaly(firstArray, secondArray);
        }
    }
}
